extends layout

block title
  title= 'Edit Post'

block content
  form(method='post')
    .control-group
      label(for='postId') ID
      .controls
        input#postId(name='post[id]', placeholder='Id', value=post?post.id:'')
        p Permalink of this post
    .control-group
      label(for='postTags')= label('Tags')
      .controls
        input#postTags(name='post[tags]', placeholder='Tags', value=post?post.tags:'')
        p Separate with comma
    .control-group
      label(for='postTime')= label('Timestamp')
      .controls
        input#postTime(name='post[postTime]', placeholder='Timestamp', value=post?post.postTime.getTime():'')
        p UNIX timestamp of post time.
    .control-group
      label(for='postClicks')= label('Clicks')
      .controls
        input#postClicks(name='post[clicks]', placeholder='Clicks', value=post?post.clicks:'0')
        p Number of views
    .control-group
      label(for='postContentsFormat')= label('Format')
      .controls
        select#postContentsFormat(name='post[contentsFormat]')
          - if (post && post.contentsFormat === 'markdown')
            option(value='markdown', selected) Markdown
          - else
            option(value='markdown') Markdown
          - if (post && post.contentsFormat === 'html')
            option(value='html', selected) HTML
          - else
            option(value='html') HTML
    .control-group
      label(for='postPrivate')= label('Private')
      .controls
        - if (post && post.private)
          input#postPrivate(type='checkbox', name='post[private]', value=1, checked)
        - else
          input#postPrivate(type='checkbox', name='post[private]', value=1)
    .control-group
      label(for='postList')= label('Show in list')
      .controls
        - if (post && post.list)
          input#postList(type='checkbox', name='post[list]', value=1, checked)
        - else
          input#postList(type='checkbox', name='post[list]', value=1)
    .control-group
      label(for='commentDisabled')= label('Comment Disabled')
      .controls
        - if (post && post.commentDisabled)
          input#commentDisabled(type='checkbox', name='post[commentDisabled]', value=1, checked)
        - else
          input#commentDisabled(type='checkbox', name='post[commentDisabled]', value=1)
    - var languages = ['zht', 'zhs', 'en']
    #tabscontainer.clearfix
      ul.tabs
        each lang in languages
          li
            a(href="#" + lang)= lang
      .tab_container
        each lang in languages
          div(id=lang).tab_content
            .control-group
              label(for='postTitle')= label('Title')
              .controls
                input#postTitle(name='post[contents][' + lang + '][title]', placeholder='Title', value=post&&post.contents[lang]?post.contents[lang].title:'')
            .control-group
              label(for='postContents')= label('Contents')
              .controls
                textarea#postContents(name='post[contents][' + lang + '][contents]', placeholder='Contents')=post&&post.contents[lang]?post.contents[lang].contents:''
    .control-group
      .controls
        input(type='submit', value=label('Save')).button
        - if (post)
          a(href='/' + post.id)= label('View post')

block scripts
